open(IN,"<liberationfont-rotate.pnm")||die;
$x=<IN>;
$x=<IN>;
$x=<IN>;
chop($x);
($w,$h)=split(/ /,$x);
$x=<IN>;
print "#include <avr/pgmspace.h>\n\nPROGMEM prog_char chars[] = {\n";

for ($r=0;$r<$h;$r++) {
    $xline = 0;
    $line="";
    for ($i=0;$i<$w;$i++) {
        $x=<IN>;$x=<IN>;$x=<IN>;
        chop($x);
        $y="0";
        $y="7" if ($x eq "255");
        $y="3" if ($x eq "170");
        $y="1" if ($x eq "85");
        $line .= "$y,";
        $xline += $y;
    }
    print "  $line\n";
}
print "};\n";

# offsets into ascii table -40
# did this by hand looking at the output above, cs[0],cl[0] means character 32 starts at font data line 216 to line 219
# -1 if that character doesn't exist in the image file

print "unsigned short chars_height = $w;\n\n";

print "unsigned short cs[59] = { 216,305,-1,325,334,-1,345,-1,361,365,355,-1,381,371,385,376,221,229,237,245,253,264,273,281,289,279,-1,-1,-1,-1,-1,-1,310,0,9,18,27,36,45,51,60,69,75,81,89,93,107,116,126,135,144,150,159,165,173,181,192,201,209 };\n\n";

print "unsigned short cl[59] = { 219,308,-1,333,343,-1,354,-1,364,369,360,-1,383,375,387,380,228,236,244,252,261,272,280,288,296,304,-1,-1,-1,-1,-1,-1,323,8,16,25,34,43,50,58,67,71,79,88,91,105,114,124,133,142,149,157,163,172,180,191,199,208,215 };\n\n";




